
package com.cn.xiaonuo.tcrfinance.tcrorder.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.xiaonuo.tcrfinance.tcrorder.entity.StorageRecord;
import com.cn.xiaonuo.tcrfinance.tcrorder.mapper.StorageRecordMapper;
import com.cn.xiaonuo.tcrfinance.tcrorder.service.StorageRecordService;
import com.cn.xiaonuo.tcrfinance.payconfig.enums.HpcEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**   
 *  
 * @Description:  买卖单不一致表——SERVICEIMPL
 * @Author:       luyangyang   
 * @CreateDate:   PvBusinessDif
 * @Version:      V1.0
 *    
 */
@Service
public class StorageRecordServiceImpl extends ServiceImpl<StorageRecordMapper, StorageRecord> implements StorageRecordService {
	private static final Logger log = LoggerFactory.getLogger(StorageRecordServiceImpl.class);
	@Resource
	StorageRecordMapper storageRecordMapper;

	/**
	 * 更新状态
	 *
	 * @author luyangyang
	 * @date 2023-01-31 15:14:02
	 */
	@Override
	public int deleteStorageRecord(Integer orderId){
		StorageRecord storageRecord = storageRecordMapper.selectOne(new QueryWrapper<>(new StorageRecord() {{
			setOrderId(orderId);
		}}));
		storageRecord.setDeleted(HpcEnum.DELETED.getCode());
		storageRecord.setRemark("取消提货审核通过");
		return storageRecordMapper.updateById(storageRecord);
	}
	/**
	 * 发货状态
	 * @param orderId
	 * @return
	 */
	@Override
	public int updateStorageRecord(Integer orderId){
		StorageRecord storageRecord = storageRecordMapper.selectOne(new QueryWrapper<>(new StorageRecord() {{
			setOrderId(orderId);
		}}));
		int i=0;
		if (storageRecord!=null) {
			storageRecord.setDeliveryTime(new Date());
			storageRecord.setRemark("提货发货");
			i =storageRecordMapper.updateById(storageRecord);
		}
		return i;
	}
}